package com.group.service.impl;

import com.group.pojo.ProductOrder;
import com.group.mapper.ProductOrderMapper;
import com.group.service.ProductOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author group
 * @since 2021-09-06
 */
@Service
public class ProductOrderServiceImpl implements ProductOrderService {
    @Autowired
    ProductOrderMapper productOrderMapper;

    @Override
    public List<ProductOrder> getOrderByUserId(Integer id) {
        return productOrderMapper.getOrderByUserId(id);
    }

    @Override
    public List<ProductOrder> getOrderByProductId(Integer id) {
        return productOrderMapper.getOrderByProductId(id);
    }

    @Override
    public boolean insertOrder(ProductOrder productOrder) {
        productOrder.setOrdercreatetime(new Date());
        return productOrderMapper.insertOrder(productOrder) > 0;
    }

    @Override
    public boolean updateOrder(ProductOrder productOrder) {
        return productOrderMapper.updateOrder(productOrder) > 0;
    }

    @Override
    public boolean deleteProductOrder(int id) {
        return productOrderMapper.deleteOrderById(id) > 0;
    }




}
